package com.jy.api.domain;

import com.jy.api.util.UuidUtil;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by lihu on 2017/12/18.
 * 某月总销售额？
 */
@Entity
@Data
@NoArgsConstructor
public class ElectronicBill {

    @Id
    @Column(length = 50)
    private String id;

    private String storeId;


    private String mchId;

    //总订单数
    private int totalSingular;


    //总销售额
    private int totalAmount;

    //总退单额
    private int refundAmount;

    //总手续费
    private int serviceChargeAmount;

    //总实收金额
    private int totalAmountIncome;

    //日期
    private Date date;

    @Column(insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date addTime;
    @Column(insertable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;


    public ElectronicBill(String storeId, String mchId, Date date, String[] total) {
        this.id = UuidUtil.getUuid();
        this.date = date;
        this.storeId = storeId;
        this.mchId = mchId;
        this.totalSingular = Integer.parseInt(total[0]);
        this.totalAmount = (int) (Double.parseDouble(total[1]) * 100);
        this.refundAmount = (int) (Double.parseDouble(total[2]) * 100);
        this.serviceChargeAmount = (int) (Double.parseDouble(total[4]) * 100);
        this.totalAmountIncome = (int) (Double.parseDouble(total[5]) * 100);
    }

}
